package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;
import com.acme.exceptions.ClientDuplicateException;
import com.acme.exceptions.ClientNotExistException;
import com.acme.exceptions.NotEnoughFundsException;

public class BankApplication {
	private Bank db = new Bank();
		
	public static void main(String[] args) throws ClientNotExistException {
		BankApplication ba = new BankApplication();
		
		try {
			BankService.addClient(ba.db, new Client(new SavingAccount(10), "Ivanov", Gender.MALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}
		try {
			BankService.addClient(ba.db, new Client(new CheckingAccount(30,20), "Petrova", Gender.FEMALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}
		try {
			BankService.addClient(ba.db, new Client(new SavingAccount(20), "Sidorova", Gender.FEMALE));
		} catch (ClientDuplicateException e) {
			e.printStackTrace();
		}
		
		try {
			BankService.addClient(ba.db, new Client(new SavingAccount(20), "Sidorova", Gender.FEMALE));
		} catch (ClientDuplicateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			BankService.modifyBank(ba.db, 1, -200);
		} catch (NotEnoughFundsException e) {
			e.printStackTrace();
		}
		
		BankService.printBalance(ba.db);
		 
		System.out.println(ba.db.getClientById(1).getClientSalutation());
	}
	
}
